#!/usr/bin/env python
# coding=utf-8

import unittest
import time
from utility import base
from utility.Graderead import *


#过期账号15142998438

class GradeHomeTests(base.BaseTests):

    #进入首页校验是否有考试按钮
    def test_goto_log3(self):
        #登出
        self.logout()
        #登录
        self.login('15142998708','123456')
        time.sleep(1)
        self.tap_tab_index(2)

        time.sleep(0.5)

        my_less_tab = self.driver.find_element_by_xpath(Gradereading.enbt_loc)
        self.assertIsNotNone(my_less_tab, u'顶部应该存在一个[我的课程]按钮')
        my_less_tab.click()

        time.sleep(0.25)

        booker_cell = self.driver.find_element_by_xpath(Gradereading.enRead_loc)
        if booker_cell: booker_cell.click()

        #过期首页
        expire_page = self.driver.find_element_by_xpath(Gradereading.enExan_loc).text
        self.assertEqual(expire_page, u'进入考试', '没有找到进入考试按钮 进入失败')
        self.driver.save_screenshot("/Users/fisher/workspace/codes/QA/testimg/考试首页15142998708.png")
        print ('进入可以参加考试首页成功')


if __name__ == '__main__':
    test_suite = unittest.TestLoader().loadTestsFromTestCase(GradeHomeTests)
    unittest.TextTestRunner().run(test_suite)